﻿namespace Probel.Client.Commands
{
    using System;
    using System.ComponentModel;
    using System.Linq;

    using Probel.Client.StatLoggerReference;

    [Command("reset", "rst", "Reset the whole database")]
    public class ResetCommand : ICommand
    {
        #region Fields

        private readonly string[] Response = new string[] { "y", "yes" };

        #endregion Fields

        #region Methods

        public void Execute(dynamic context)
        {
            var proxy = context.ProxyLogger as IStatLogger;
            var input = context.Input as Input;

            var result = input.Read("Do you want to delete all the statistics? (Y(es)/N(o)): ");
            if (Response.Contains(result.ToLower()))
            {
                Console.Write("Deleting data...");
                proxy.ClearStatistics();
                Console.WriteLine(" Done");
            }
            else { Console.WriteLine("Cancelled"); }
        }

        #endregion Methods
    }
}